package com.srzk.youthleagueback.controller;

import com.srzk.youthleagueback.entity.po.Student;
import com.srzk.youthleagueback.results.Result;
import com.srzk.youthleagueback.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@RequestMapping("/student")
public class StudentController {

    @Autowired
    StudentService studentService;

    @RequestMapping("/update")
    public Result<Student> update(Student student){
        return studentService.updateStudent(student);
    }
    @RequestMapping("/get")
    public Result<Student> get(String username){
        return studentService.get(username);
    }

    @RequestMapping("/delete")
    public Result<String> delete(String username){
        return studentService.delete(username);
    }

    @RequestMapping("add")
    public Result<String> getByUserName(Student student){
        return studentService.add(student);
    }
}
